<%@ page language="java" isELIgnored="false" import="java.util.*" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>抓取数据导出</title>
<script type="text/javascript" src="<%=request.getContextPath() %>/fare/js/jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/fare/js/datePicker/WdatePicker.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/FusionCharts/FusionCharts.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/fare/lib/ligerUI/js/ligerui.min.js"></script>
<link href="<%=request.getContextPath() %>/fare/lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
<link href="<%=request.getContextPath() %>/fare/css/base.css" rel="stylesheet" type="text/css" />
<!-- 圆角文本框 -->
<link href="<%=request.getContextPath() %>/fare/css/htc/htc.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=request.getContextPath()%>/jsFile/common.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/jsFile/multiblepicker.js"></script>
<script>

function compareTime(startDate, endDate) {  
	 if (startDate.length > 0 && endDate.length > 0) {  
	    var startDateTemp = startDate.split(" ");  
	    var endDateTemp = endDate.split(" ");  
	                  
	    var arrStartDate = startDateTemp[0].split("-");  
	    var arrEndDate = endDateTemp[0].split("-");  
	  
	    var arrStartTime = startDateTemp[1].split(":");  
	    var arrEndTime = endDateTemp[1].split(":");  
	  
	var allStartDate = new Date(arrStartDate[0], arrStartDate[1], arrStartDate[2], arrStartTime[0], arrStartTime[1], arrStartTime[2]);  
	var allEndDate = new Date(arrEndDate[0], arrEndDate[1], arrEndDate[2], arrEndTime[0], arrEndTime[1], arrEndTime[2]);  
	                  
	if (allStartDate.getTime() >= allEndDate.getTime()) {
	        return false;  
	} else { 
	    return true;  
	}
  }
}



function currentDate(){ 
    var now = new Date();       
    var year = now.getFullYear();
    var month = now.getMonth() + 1;
    var day = now.getDate();
    var hours = now.getHours();
    var today = year + "-";       
    if(month < 10)
        today += "0";       
    today += month + "-";       
    if(day < 10)
        today += "0";           
    today += day; 
    today += " "+hours;
    return(today); 
}

function showLigerComboBox(pickerId,url,columns,tableWidth,field,check) {
	var condition = {};
	var dep = $('#depCity').val();
	var arr = $('#arrCity').val();
	if(dep !="中文/拼音"&&dep&&arr !="中文/拼音"&&arr){
		condition = {depCity:dep,arrCity:arr};
	}
	
	$.ajax({
        url : url,
        data: condition,
        cache : false, 
        async : false,
        type : "POST",
       	complete: function(jqXHR, textStatus){
       		var data;
       		if(jqXHR.status==200){
       			data = parseObj(jqXHR.responseText)
       		}
       		var options = {
                    columns: columns,
                    switchPageSizeApplyComboBox: false,
                    data: $.extend({}, data),
                    pageSize: 10, 
                    checkbox: check
                };
       		$('#'+pickerId).ligerComboBox({
       			width : 150,
       			slide : false,
       			selectBoxWidth : tableWidth,
       			selectBoxHeight : 310,
       			valueField : field,
       			textField : field,
       			grid : options,
       			split: ","
       		});
       	}
    });
}



$(function(){
	//$("#grapDate").ligerDateEditor({format:'yyyy-MM-dd hh',showTime:true});
	var today = currentDate();
	$("#grapDate").val(today);
	$("#channels").ligerComboBox(); 
	
	
	var status = '<%=request.getAttribute("status")%>';
	if(status == "nodata"){
		$.ligerDialog.error('查无数据，请重新选择查询条件');
	}
	if(status == "error"){
		$.ligerDialog.error('下载出错，请联系管理员');
	}
	
	
});

function submitForm(){
	var grapDate = $("#grapDate").val();
	if(grapDate == ''){
		$.ligerDialog.error('请设置抓取时间');
		return;
	}
	
	if(!compareTime(grapDate,currentDate())){
		$.ligerDialog.error('抓取时间,必须小于当前时间');
		return;
		
	}
	$("#channel").submit();
}
</script>

</head>

<body>
<form id="channel" method="post" action="<%=request.getContextPath()%>/captureDataExportAction!export.action">
<TABLE cellSpacing=1 cellPadding=3 width="100%" border=0 class="tabg" style="border-collapse: separate;border-spacing: 1px;">
  <TR class="tr1">
    <TD colspan="4" style="color:white;">查询条件 </TD>
  </TR>
  <TR class="tab">
    <TD height="26" class="td1" style="text-align:left">抓取日期：<span style="color:#ff0000">yyyy-mm-dd hh</span></TD>
  	<TD>
  	  <input name="grapDate" type="text" id="grapDate"  onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH'})" >
  	  
  	</TD>
    <TD width="10%" height="26" class="td1" style="text-align:left">网站名称：</TD>
  	<TD width="40%">
  	  <select id="channels" name="channels">
  	  	<c:forEach var="bean" items="${seList}" varStatus="stat">
  	  		<option value="${bean.hbaseKey }">${bean.name }</option>
  	  	</c:forEach>
  	  </select>
  	</TD>
  </TR>
  <TR class="tab">
    <TD height="26" align="center" colspan="4">
      <input type="button"  value="导出Excel" onclick="javascript:submitForm();" id="sub1" style="width:80px;">
    </TD>
  </TR>
</TABLE>
</form>
</body>
</html>

